package com.skyworth.skymanualActivity;
import java.util.ArrayList;
import java.util.HashMap;
import com.skyworth.skymanualdata.ContentData;
import com.skyworth.skymanualdata.DataAdapter;
import com.skyworth.skymanualdata.Page;
import com.skyworth.skymanualdata.SkyworthKeyCode;
import com.skyworth.skymanual.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class ContentActivity extends Activity{
    private ListView stringListView;
	private TextView mythirdViewPageText;
	private int thirdViewPageSum=0;
	private ListView onlystringListView;
	private ArrayList<HashMap<String, Object>> list;
	DataAdapter mListViewAdapter;
	ArrayList<HashMap<String, Object>> listItem;
	public int picindex = 1;
	private static int number = 0;
	private String ReceiveStr;
	Intent intent;	
	FrameLayout mylayout;
	ImageView imageWindow, imageOne, imageTwo1, imageTwo2, imageThree1,
			imageThree2, imageThree3, imageThree4, imageFour1, imageFour2,
			imageFour3, imageFour4,admin_image;
	TextView marktext;
	private int commonView = 0, settingView = 1, sharingView = 2, playView = 3,
			adminView = 4, movieView = 5, mediaView = 6, questionView = 7;
    private ContentData thirdViewData = new ContentData();
	private int thirdViewIndex = 0;
	private static int type_thirdview_PictureString = 1;
	private static int type_thirdview_TelePictureString = 2;
	private static int type_thirdview_OnlyString = 3;
	private static int type_thirdview_Help = 4;
	private static int type_thirdview_RemotePictureString = 5;
	private static int type_thirdview_onlyPicture=6;	
	private int SecondViewPageid=0;
	private Animation animationLayoutRight, animationLayoutLeft;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE); 
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN); 
		Intent intent = getIntent();
		ReceiveStr = intent.getStringExtra("id");
		Log.i("lhy","third view receiveStr="+ReceiveStr);
		SecondViewPageid=Integer.parseInt(ReceiveStr);
		Log.i("lhy","secondViewPageid="+SecondViewPageid);
		listcreate();
		thirdViewIndex = 0;
    	updatathirdview();    	
    	System.gc();
    }
	
	

	void updatathirdview() {
		int itemTypeview = 0;
		if(ContentData.viewtype==commonView){
			itemTypeview = type_thirdview_PictureString;
			thirdViewPageSum=thirdViewData.myCommonPageNum;
			updataThirdViewData(thirdViewData.myCommonPage[thirdViewIndex],
					itemTypeview);
		}else if(ContentData.viewtype==settingView){
			if(SecondViewPageid==1){
				itemTypeview = type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.mySetting_netPageNum;
				updataThirdViewData(thirdViewData.mySetting_netPage[thirdViewIndex],
						itemTypeview);
			}else if(SecondViewPageid==2){
				itemTypeview = type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.mySetting_bluePageNum;
				updataThirdViewData(thirdViewData.mySetting_bluePage[thirdViewIndex],
						itemTypeview);
			}else if(SecondViewPageid==3){
				itemTypeview = type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.mySetting_updataPageNum;
				updataThirdViewData(thirdViewData.mySetting_updataPage[thirdViewIndex],
						itemTypeview);
			}
		}else if(ContentData.viewtype==sharingView){
			if(SecondViewPageid==1){
				itemTypeview = type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.mySharing_cloudPageNum;
				updataThirdViewData(thirdViewData.mySharing_cloudPage[thirdViewIndex],
						itemTypeview);
			}else if(SecondViewPageid==2){
				itemTypeview = type_thirdview_TelePictureString;
				if(thirdViewIndex==0){					
					imageTwo1.setImageResource(R.drawable.tele1);
				}else if(thirdViewIndex==1){
					imageTwo1.setImageResource(R.drawable.tele2);
				}else if(thirdViewIndex==2){
					imageTwo1.setImageResource(R.drawable.tele3);
				}else if(thirdViewIndex==3){
					imageTwo1.setImageResource(R.drawable.tele4);
				}else if(thirdViewIndex==4){
					imageTwo1.setImageResource(R.drawable.tele5);
				}
				
				thirdViewPageSum=thirdViewData.mySharing_tvPageNum;
				updataThirdViewData(thirdViewData.mySharing_tvPage[thirdViewIndex],
						itemTypeview);
			}else if(SecondViewPageid==3){
				itemTypeview = type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.mySharing_mirPageNum;
				updataThirdViewData(thirdViewData.mySharing_mirPage[thirdViewIndex],
						itemTypeview);
			}else if(SecondViewPageid==4){
				itemTypeview = type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.mySharing_skyPageNum;
				updataThirdViewData(thirdViewData.mySharing_skyPage[thirdViewIndex],
						itemTypeview);
			}
		}else if(ContentData.viewtype==playView){
			if(SecondViewPageid==1){
				itemTypeview=type_thirdview_PictureString;
		        thirdViewPageSum=thirdViewData.myPlay_gamePageNum;
		        updataThirdViewData(thirdViewData.myPlay_gamePage[thirdViewIndex]
		        		,itemTypeview);
		        
			}else if(SecondViewPageid==2){
				itemTypeview=type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.myPlay_applyPageNum;
				updataThirdViewData(thirdViewData.myPlay_applyPage[thirdViewIndex],itemTypeview);
			}else if(SecondViewPageid==3){
				itemTypeview=type_thirdview_PictureString;
				thirdViewPageSum=thirdViewData.myPlay_shoppingPageNum;
				updataThirdViewData(thirdViewData.myPlay_shoppingPage[thirdViewIndex],itemTypeview);
			}
		    
		}else if (ContentData.viewtype == movieView) {	
			itemTypeview=type_thirdview_PictureString;
			thirdViewPageSum=thirdViewData.myMoviePageNum;
			Log.i("lhy", "******picindex=" + picindex + "  ;" + "number="
					+ number + "  ;" + "thirdViewIndex= " + thirdViewIndex);

			/*** test ***/
			updataThirdViewData(thirdViewData.myMoviePage[thirdViewIndex],
					itemTypeview);
		}else if(ContentData.viewtype==adminView){
			if(thirdViewIndex==0){
				itemTypeview = type_thirdview_onlyPicture;
			}else{
			    itemTypeview = type_thirdview_PictureString;
			}
			thirdViewPageSum=thirdViewData.myAdminPageNum;
			updataThirdViewData(thirdViewData.myAdminPage[thirdViewIndex],
					itemTypeview);
		}else if(ContentData.viewtype==mediaView){
			thirdViewPageSum=thirdViewData.myMediaPageNum;
			itemTypeview=type_thirdview_PictureString;
			updataThirdViewData(thirdViewData.myMediaPage[thirdViewIndex],itemTypeview);
		}else if(ContentData.viewtype==questionView){
			if(SecondViewPageid==1){
				itemTypeview = type_thirdview_OnlyString;
				thirdViewPageSum=thirdViewData.myQuestionPageNum;
				updataThirdViewData(thirdViewData.myQuestionPage[thirdViewIndex],
						itemTypeview);
			}else if(SecondViewPageid==2){
				itemTypeview = type_thirdview_Help;
				thirdViewPageSum=thirdViewData.myConnectPageNum;
				updataThirdViewData(thirdViewData.myConnectPage[thirdViewIndex],
						itemTypeview);
			}
		}
	}	
	void listcreate() {
		setContentView(R.layout.activity_list);
		stringListView = (ListView) findViewById(R.id.lv);
		onlystringListView = (ListView) findViewById(R.id.onlytextlayout);
		onlystringListView.setFocusable(false);
		onlystringListView.setFocusableInTouchMode(false);
		onlystringListView.setEnabled(false);
		imageWindow = (ImageView) findViewById(R.id.imageWindow);
		imageOne = (ImageView) findViewById(R.id.imageOne);
		imageTwo1 = (ImageView) findViewById(R.id.imageTwo1);
		imageTwo2 = (ImageView) findViewById(R.id.imageTwo2);
		imageThree1 = (ImageView) findViewById(R.id.imageThree1);
		imageThree2 = (ImageView) findViewById(R.id.imageThree2);
		imageThree3 = (ImageView) findViewById(R.id.imageThree3);
		imageThree4 = (ImageView) findViewById(R.id.imageThree4);
        imageFour1 = (ImageView) findViewById(R.id.imageFour1);
		imageFour2 = (ImageView) findViewById(R.id.imageFour2);
		imageFour3 = (ImageView) findViewById(R.id.imageFour3);
		imageFour4 = (ImageView) findViewById(R.id.imageFour4);
        admin_image=(ImageView)findViewById(R.id.imageadmin);
		marktext = (TextView) findViewById(R.id.marktext);
		mylayout = (FrameLayout) findViewById(R.id.mylayout);
		list = new ArrayList<HashMap<String, Object>>();
		animationLayoutRight = AnimationUtils.loadAnimation(
				ContentActivity.this, R.anim.layoutright);
		animationLayoutLeft = AnimationUtils.loadAnimation(ContentActivity.this,
				R.anim.layoutleft);
		stringListView.setFocusable(false);
		stringListView.setFocusableInTouchMode(false);
		stringListView.setEnabled(false);
	}

		private void updataThirdViewData(Page page, int myviewtype) {
			Log.i("lhy", "***********init third View data");
			stringListView = (ListView) findViewById(R.id.lv);
			onlystringListView = (ListView) findViewById(R.id.onlytextlayout);
			mythirdViewPageText=(TextView)findViewById(R.id.pagenumber);
			list = new ArrayList<HashMap<String, Object>>();
			for (int i = 0; i < page.text.length; i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				map.put("ItemText", page.text[i]);
				list.add(map);
			}
			if (myviewtype == type_thirdview_OnlyString
					|| myviewtype == type_thirdview_Help) {
				Log.v("lhy", "onlyString");
				mListViewAdapter = new DataAdapter(this, list, page.key,
						page.color, page.title_position,2);
				onlystringListView.setAdapter(mListViewAdapter);
				onlystringListView.setVisibility(View.VISIBLE);
				stringListView.setVisibility(View.INVISIBLE);
			} else {
				Log.v("lhy", "String and picture");
				mListViewAdapter = new DataAdapter(this, list, page.key,
						page.color,page.title_position, 1);
				stringListView.setAdapter(mListViewAdapter);
				onlystringListView.setVisibility(View.INVISIBLE);
				stringListView.setVisibility(View.VISIBLE);
			}

			Log.v("lhy","the page color is "+page.color);			
			mylayout.setBackgroundColor(page.backgroundcolor);
			marktext.setText(page.markstr);
			mythirdViewPageText.setText(thirdViewIndex+1+"/"+thirdViewPageSum);
			if (myviewtype == type_thirdview_PictureString) {
				imageWindow.setVisibility(View.VISIBLE);
				imageOne.setVisibility(View.VISIBLE);
				imageOne.setImageResource(page.image);
				imageTwo1.setVisibility(View.INVISIBLE);
				imageTwo2.setVisibility(View.INVISIBLE);
				imageThree1.setVisibility(View.INVISIBLE);
				imageThree2.setVisibility(View.INVISIBLE);
				imageThree3.setVisibility(View.INVISIBLE);
				imageThree4.setVisibility(View.INVISIBLE);
				imageFour1.setVisibility(View.INVISIBLE);
				imageFour2.setVisibility(View.INVISIBLE);
				imageFour3.setVisibility(View.INVISIBLE);
				imageFour4.setVisibility(View.INVISIBLE);
				admin_image.setVisibility(View.INVISIBLE);
			} else if (myviewtype == type_thirdview_Help) {
				imageWindow.setVisibility(View.INVISIBLE);
				imageOne.setVisibility(View.INVISIBLE);
				imageTwo2.setImageResource(R.drawable.connect);
				imageTwo1.setVisibility(View.INVISIBLE);
				imageTwo2.setVisibility(View.VISIBLE);
				imageThree1.setVisibility(View.INVISIBLE);
				imageThree2.setVisibility(View.INVISIBLE);
				imageThree3.setVisibility(View.INVISIBLE);
				imageThree4.setVisibility(View.INVISIBLE);
				imageFour1.setVisibility(View.INVISIBLE);
				imageFour2.setVisibility(View.INVISIBLE);
				imageFour3.setVisibility(View.INVISIBLE);
				imageFour4.setVisibility(View.INVISIBLE);
				admin_image.setVisibility(View.INVISIBLE);
			}else if (myviewtype == type_thirdview_onlyPicture) {
				imageWindow.setVisibility(View.INVISIBLE);
				imageOne.setVisibility(View.INVISIBLE);
				admin_image.setVisibility(View.VISIBLE);
				admin_image.setImageResource(page.image);
				imageFour4.setVisibility(View.INVISIBLE);
				imageTwo1.setVisibility(View.INVISIBLE);
				imageTwo2.setVisibility(View.INVISIBLE);
				imageThree1.setVisibility(View.INVISIBLE);
				imageThree2.setVisibility(View.INVISIBLE);
				imageThree3.setVisibility(View.INVISIBLE);
				imageThree4.setVisibility(View.INVISIBLE);
				imageFour1.setVisibility(View.INVISIBLE);
				imageFour2.setVisibility(View.INVISIBLE);
				imageFour3.setVisibility(View.INVISIBLE);
				
			} else if (myviewtype == type_thirdview_TelePictureString) {
				imageWindow.setVisibility(View.VISIBLE);
				imageOne.setVisibility(View.VISIBLE);
				imageOne.setImageResource(page.image);
				imageTwo1.setVisibility(View.VISIBLE);
				
				imageTwo2.setVisibility(View.INVISIBLE);
				imageThree1.setVisibility(View.INVISIBLE);
				imageThree2.setVisibility(View.INVISIBLE);
				imageThree3.setVisibility(View.INVISIBLE);
				imageThree4.setVisibility(View.INVISIBLE);

				imageFour1.setVisibility(View.INVISIBLE);
				imageFour2.setVisibility(View.INVISIBLE);
				imageFour3.setVisibility(View.INVISIBLE);
				imageFour4.setVisibility(View.INVISIBLE);
				admin_image.setVisibility(View.INVISIBLE);
				
			} else if (myviewtype == type_thirdview_RemotePictureString) {
				imageWindow.setVisibility(View.VISIBLE);
				imageOne.setVisibility(View.VISIBLE);
				imageOne.setImageResource(page.image);
				imageTwo1.setImageResource(R.drawable.shortremote);
				imageTwo1.setVisibility(View.VISIBLE);
				imageTwo2.setVisibility(View.INVISIBLE);
				imageThree1.setVisibility(View.INVISIBLE);
				imageThree2.setVisibility(View.INVISIBLE);
				imageThree3.setVisibility(View.INVISIBLE);
				imageThree4.setVisibility(View.INVISIBLE);
				imageFour1.setVisibility(View.INVISIBLE);
				imageFour2.setVisibility(View.INVISIBLE);
				imageFour3.setVisibility(View.INVISIBLE);
				imageFour4.setVisibility(View.INVISIBLE);
				admin_image.setVisibility(View.INVISIBLE);
			} else if (myviewtype == type_thirdview_OnlyString) {
				imageWindow.setVisibility(View.INVISIBLE);
				imageOne.setVisibility(View.INVISIBLE);
				imageTwo1.setVisibility(View.INVISIBLE);
				imageTwo2.setVisibility(View.INVISIBLE);
				imageThree1.setVisibility(View.INVISIBLE);
				imageThree2.setVisibility(View.INVISIBLE);
				imageThree3.setVisibility(View.INVISIBLE);
				imageThree4.setVisibility(View.INVISIBLE);
				imageFour1.setVisibility(View.INVISIBLE);
				imageFour2.setVisibility(View.INVISIBLE);
				imageFour3.setVisibility(View.INVISIBLE);
				imageFour4.setVisibility(View.INVISIBLE);
				admin_image.setVisibility(View.INVISIBLE);
			} 

		}
		
		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			// TODO Auto-generated method stub
			switch (keyCode) {
			case SkyworthKeyCode.SKY_KEY_RIGHT:
			case SkyworthKeyCode.SKY_KEY_SHORT_SHUTTLE_RIGHT:
			{
					Log.i("lhy", "***********flag=3;key right********");
					mylayout.startAnimation(animationLayoutRight);
					listcreate();

					if(ContentData.viewtype==commonView){
						thirdViewIndex++;
						if (thirdViewIndex == thirdViewData.myCommonPageNum) {
							thirdViewIndex = 0;
						}
						updatathirdview();
						number++;
					}else if (ContentData.viewtype == movieView) {
						thirdViewIndex++;
						if (thirdViewIndex == thirdViewData.myMoviePageNum) {
							thirdViewIndex = 0;
						}
						Log.i("lhy", "movieView******picindex=" + picindex + "  ;"
								+ "number=" + number + "  ;" + "thirdViewIndex= "
								+ thirdViewIndex);
						updatathirdview();
						number++;
					}else if (ContentData.viewtype == settingView) {
						if(SecondViewPageid==1){							
	   					    thirdViewIndex++;
	   					   if (thirdViewIndex == thirdViewData.mySetting_netPageNum) {
								thirdViewIndex = 0;
								SecondViewPageid=2;
							}
						    updatathirdview();
						    number++;
						}else if(SecondViewPageid==2){
		   					 thirdViewIndex++;
		   					 if (thirdViewIndex == thirdViewData.mySetting_bluePageNum) {
							    thirdViewIndex = 0;
							    SecondViewPageid=3;
						      }
							 updatathirdview();
							 number++;
							
						}else if(SecondViewPageid==3){
		   					 thirdViewIndex++;
		   					 if (thirdViewIndex == thirdViewData.mySetting_updataPageNum) {
							     thirdViewIndex = 0;
							     SecondViewPageid=1;
						      }
							 updatathirdview();
							 number++;
						 }
					}else if (ContentData.viewtype==sharingView){
						if(SecondViewPageid==1){
	   					    thirdViewIndex++;
	   					   if (thirdViewIndex == thirdViewData.mySharing_cloudPageNum) {
								thirdViewIndex = 0;
								SecondViewPageid=2;
							}
						    updatathirdview();
						    number++;
						}else if(SecondViewPageid==2){
		   					 thirdViewIndex++;
		   					 if (thirdViewIndex == thirdViewData.mySharing_tvPageNum) {
							    thirdViewIndex = 0;
							    SecondViewPageid=3;
						      }
							 updatathirdview();
							 number++;
							
						}else if(SecondViewPageid==3){
		   					 thirdViewIndex++;
		   					 if (thirdViewIndex == thirdViewData.mySharing_mirPageNum) {
							    thirdViewIndex = 0;
							    SecondViewPageid=4;
						      }
							 updatathirdview();
							 number++;
						 }else if(SecondViewPageid==4){
		   					 thirdViewIndex++;
		   					 if (thirdViewIndex == thirdViewData.mySharing_skyPageNum) {
							    thirdViewIndex = 0;
							    SecondViewPageid=1;
						      }
							 updatathirdview();
							 number++;
						 }				
					}else if(ContentData.viewtype==playView){
						if(SecondViewPageid==1){
							thirdViewIndex++;
							if (thirdViewIndex == thirdViewData.myPlay_gamePageNum) {
								thirdViewIndex = 0;
								SecondViewPageid=2;
								
							}
							Log.i("lhy", "play******picindex=" + picindex
									+ "  ;" + "number=" + number + "  ;"
									+ "thirdViewIndex= " + thirdViewIndex);
							updatathirdview();
							number++;
						 }else if(SecondViewPageid==2){
							 thirdViewIndex++;
							 if(thirdViewIndex==thirdViewData.myPlay_applyPageNum){
								 thirdViewIndex=0;
								 SecondViewPageid=3;
							 }
							 updatathirdview();
							 number++;
						 }else if(SecondViewPageid==3){
							 thirdViewIndex++;
							 if(thirdViewIndex==thirdViewData.myPlay_shoppingPageNum){
								 thirdViewIndex=0;
								 SecondViewPageid=1;
							 }
							 updatathirdview();
							 number++;
						 }
					}else if(ContentData.viewtype==adminView){
						thirdViewIndex++;
						if (thirdViewIndex == thirdViewData.myAdminPageNum) {
							thirdViewIndex = 0;
						}
						Log.i("lhy", "question******picindex=" + picindex
								+ "  ;" + "number=" + number + "  ;"
								+ "thirdViewIndex= " + thirdViewIndex);
						updatathirdview();
						number++;
					}else if(ContentData.viewtype==mediaView){
						thirdViewIndex++;
						if(thirdViewIndex==thirdViewData.myMediaPageNum){
							thirdViewIndex=0;
						}
						updatathirdview();
						number++;
					}else if (ContentData.viewtype == questionView) {
						if (SecondViewPageid == 1) {
							thirdViewIndex++;
							if (thirdViewIndex == thirdViewData.myQuestionPageNum) {
								thirdViewIndex = 0;
								SecondViewPageid=2;
							}
							Log.i("lhy", "question******picindex=" + picindex
									+ "  ;" + "number=" + number + "  ;"
									+ "thirdViewIndex= " + thirdViewIndex);
							updatathirdview();
							number++;
						} else if (SecondViewPageid == 2) {
							thirdViewIndex++;
							if (thirdViewIndex == thirdViewData.myConnectPageNum) {
								thirdViewIndex = 0;
								SecondViewPageid=1;
							}
							Log.i("lhy", "question******picindex=" + picindex
									+ "  ;" + "number=" + number + "  ;"
									+ "thirdViewIndex= " + thirdViewIndex);
							updatathirdview();
							number++;
						}
					}
                System.gc();
				
			}
				return true;
			case SkyworthKeyCode.SKY_KEY_LEFT: 
			case SkyworthKeyCode.SKY_KEY_SHORT_SHUTTLE_LEFT:
			{
					Log.i("lhy", "***********flag=3;key left********");
					mylayout.startAnimation(animationLayoutLeft);
					listcreate();
					if(ContentData.viewtype==commonView){
						thirdViewIndex--;
						if (thirdViewIndex == -1) {
							thirdViewIndex = thirdViewData.myCommonPageNum - 1;
						}
						updatathirdview();
					}else if (ContentData.viewtype == settingView) {
						if(SecondViewPageid==1){
	   					    thirdViewIndex--;
						    if (thirdViewIndex == -1) {
							    
							    thirdViewIndex = thirdViewData.mySetting_updataPageNum - 1;
							    SecondViewPageid=3;
						    }
						    updatathirdview();
						    number--;
						}else if(SecondViewPageid==2){
	   					    thirdViewIndex--;
						    if (thirdViewIndex == -1) {
							    
							    thirdViewIndex = thirdViewData.mySetting_netPageNum - 1;
							    SecondViewPageid=1;
						    }
						    updatathirdview();
						    number--;
						}else if(SecondViewPageid==3){
							thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	thirdViewIndex = thirdViewData.mySetting_bluePageNum - 1;
							    SecondViewPageid=2;
							    
						    }
						    updatathirdview();
						    number--;
						}
					}else if(ContentData.viewtype==sharingView){
						if(SecondViewPageid==1){
	   					    thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	thirdViewIndex = thirdViewData.mySharing_skyPageNum - 1;
							   
							    SecondViewPageid=4;
						    }
						    updatathirdview();
						    number--;
						}else if(SecondViewPageid==2){
	   					    thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	thirdViewIndex = thirdViewData.mySharing_cloudPageNum - 1;
							   
							    SecondViewPageid=1;
						    }
						    updatathirdview();
						    number--;
						}else if(SecondViewPageid==3){
							thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	 thirdViewIndex = thirdViewData.mySharing_tvPageNum - 1;
							   
							    SecondViewPageid=2;
						    }
						    updatathirdview();
						    number--;
						}else if(SecondViewPageid==4){
							thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	 thirdViewIndex = thirdViewData.mySharing_mirPageNum - 1;
							    SecondViewPageid=3;
						    }
						    updatathirdview();
						    number--;
						}
					}else if(ContentData.viewtype==playView){
						if(SecondViewPageid==1){
							thirdViewIndex--;
							if (thirdViewIndex == -1) {
								thirdViewIndex=thirdViewData.myPlay_shoppingPageNum-1;
								
								SecondViewPageid=3;
							}
							updatathirdview();
						}else if(SecondViewPageid==2){
							thirdViewIndex--;
							if(thirdViewIndex==-1){
								thirdViewIndex = thirdViewData.myPlay_gamePageNum - 1;
								
								SecondViewPageid=1;
							}
							updatathirdview();
						}else if(SecondViewPageid==3){
							thirdViewIndex--;
							if(thirdViewIndex==-1){
								thirdViewIndex=thirdViewData.myPlay_applyPageNum-1;
								SecondViewPageid=2;
							}
							updatathirdview();
						}
					}else if(ContentData.viewtype==adminView){
						thirdViewIndex--;
						if (thirdViewIndex == -1) {
							thirdViewIndex = thirdViewData.myAdminPageNum - 1;
						}
						updatathirdview();
					}else if (ContentData.viewtype == movieView) {
						thirdViewIndex--;
						if (thirdViewIndex == -1) {
							thirdViewIndex = thirdViewData.myMoviePageNum - 1;
						}
						updatathirdview();
						number--;

					}else if(ContentData.viewtype==mediaView){
						thirdViewIndex--;
						if(thirdViewIndex==-1){
							thirdViewIndex=thirdViewData.myMediaPageNum-1;
						}
						updatathirdview();
						number--;
					}else if (ContentData.viewtype == questionView) {
						if(SecondViewPageid==1){
	   					    thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	thirdViewIndex = thirdViewData.myConnectPageNum - 1;
							   
							    SecondViewPageid=2;
						    }
						    updatathirdview();
						    number--;
						}else if(SecondViewPageid==2){
							thirdViewIndex--;
						    if (thirdViewIndex == -1) {
						    	thirdViewIndex = thirdViewData.myQuestionPageNum - 1;
						    	 SecondViewPageid=1;
						    }
						    updatathirdview();
						    number--;
						}
					}
				
					System.gc();
			}
				return true;
			case SkyworthKeyCode.SKY_KEY_CENTER: {
			}
				return true;
			case SkyworthKeyCode.SKY_KEY_UP: {

			}
				return true;
			case SkyworthKeyCode.SKY_KEY_DOWN: {

			}
				return true;

			case SkyworthKeyCode.SKY_KEY_BACK: {
				System.gc();
				finish();

			}
				return true;
			default:
				break;
			}
			return super.onKeyDown(keyCode, event);

		}
		
}
